<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="ESP.VO.Role"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <jsp:include page="../include.jsp" flush="true"/>
    <script type="text/javascript">
    	function checkOldPsw(){
    		var oldPsw = $("#oldPassword").val();
    		$.post('e03!checkOldPsw',
    			{oldPassword:oldPsw, user_id:user_id},
    			function(message){
    				$("#p1").remove();
    				$("#check1").append("<td id='p1' align='right' style='color:red'>"+message.returnMsg+"</td>");
    				if (message.returnFlag == 'N' && user_id != null) {
						$('#oldPassword').focus();
					}
    			}
    		);
    	}
    	function checkNewPsw(){
    		var newPsw = $("#newPassword").val();
    		$("#p2").remove();
    		if (newPsw.length < 6) {
    			$("#check2").append("<td id='p2' align='right' style='color:red'>密码长度不足6位</td>");
				return false;
			}else if(newPsw.length > 15){
				$("#check2").append("<td id='p2' align='right' style='color:red'>密码长度超过15位</td>");
				return false;
			}else{
				$("#check2").append("<td id='p2' align='right' style='color:red'>校验通过!</td>");
				return true;
			}
    	}
    	function checkNewPsw2(){
    		var newPsw = $("#newPassword").val();
    		var newPsw2 = $("#newPassword2").val();
    		$("#p3").remove();
    		if (newPsw != newPsw2) {
    			$("#check3").append("<td id='p3' align='right' style='color:red'>两次密码输入不一致</td>");
				return false;
			}else{
				$("#check3").append("<td id='p3' align='right' style='color:red'>校验通过!</td>");
				return true;
			}
    	}
    	function save(){
    		if(!(checkNewPsw() && checkNewPsw2())){
    			alert("请按照要求输入!");
    			return false;
    		}
    		var oldPsw = $("#oldPassword").val();
	    	var newPsw = $("#newPassword").val();
	    	var newPsw2 = $("#newPassword2").val();
    		$.post(
    			'e03!modifyPassword',
    			{user_id:user_id, newPassword:newPsw, oldPassword:oldPsw},
    			function(message){
    				show(message.returnMsg);
    				$('#userform').form('clear');
    				$('#p1').remove();
    				$('#p2').remove();
    				$('#p3').remove();
    			}
    		);
    	}
    </script>
  </head>
  <body>
  	<div id="stuwindow" class="easyui-window" title="用户中心>>密码修改" style="padding:10px;width:600px;height:350px;"
  			data-options="modal:true,maximizable:false,collapsible:false,fit:true,
  						  minimizable:false,closable:false,closed:false,draggable:false,resizable:false,inline:false
  					">
  		<center>
		<form id="userform" method="post">
		  	<table border="0"  cellpadding="0">
		  		<tr>
		  			<td bgcolor="#ebebeb" style="width:500px;" align="right">原密码：</td>
		  			<td bgcolor="#ebebeb" style="width:500px;" align="left">
		  				<input type="password" name="oldPassword" id="oldPassword" onblur="checkOldPsw()" >
		  			</td>
		  		</tr>
		  		<tr>
		  			<td>&nbsp;</td>
		  			<td id="check1"></td>
		  		</tr>
		  		<tr>
		  			<td bgcolor="#ebebeb" style="width:500px;" align="right">新密码：</td>
		  			<td bgcolor="#ebebeb" style="width:500px;" align="left">
		  				<input type="password" name="newPassword" id="newPassword" onblur="checkNewPsw()">
		  			</td>
		  		</tr>
		  		<tr>
		  			<td>&nbsp;</td>
		  			<td id="check2"></td>
		  		</tr>
		  		<tr>
		  			<td bgcolor="#ebebeb" style="width:500px;" align="right">确认密码：</td>
		  			<td bgcolor="#ebebeb" style="width:500px;" align="left">
		  				<input type="password" name="newPassword2" id="newPassword2" onblur="checkNewPsw2()">
		  			</td>
		  		</tr>
		  		<tr>
		  			<td></td>
		  			<td id="check3"></td>
		  		</tr>
		  		<tr>
		  			<td></td>
		  			<td>&nbsp;</td>
		  		</tr>
		  		<tr>
		  			<td align="center"><a href="javascript:void(0)" onclick="save()" class="easyui-linkbutton" icon="icon-save">确认</a></td>
		  			<td align="center"><a href="javascript:void(0)" onclick="cancel()" class="easyui-linkbutton" id="btn-cancel" icon="icon-cancel">取消</a></td>
		  		</tr>
			</table>
		</form>
		<hr/>
		</center>
		<font >密码规则：<br/><br/>
			&nbsp;&nbsp;&nbsp;&nbsp;1、密码长度应至少<font color="red">6</font>位,至多<font color="red">15</font>位！<br/><br/>
			&nbsp;&nbsp;&nbsp;&nbsp;2、为保证安全,请使用较为复杂的密码！
		</font>
	</div>
	<script type="text/javascript">
		function cancel(){
			$('#userform').form('clear');
			$('p').remove();
		}
	</script>
  </body>
</html>
